//
//  SecondCarOrderDetailTableViewCell.m
//  OneCreditTreasure
//
//  Created by iOS Tedu on 16/8/29.
//
//

#import "SecondCarOrderDetailTableViewCell.h"

#define myOwnLBSettings(label)\
label.numberOfLines = 0;\
label.textAlignment = NSTextAlignmentCenter;\
label.font = [UIFont systemFontOfSize:14 * AUTO_WIDTH];\
label.layer.borderWidth = 1;\
label.layer.borderColor = [[UIColor lightGrayColor] CGColor];

@implementation SecondCarOrderDetailTableViewCell
#pragma mark - 生命周期 life cycle
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self infoView];
    }
    return self;
}

#pragma mark - 懒加载 lazy loading
- (UIView *)infoView {
    if(_infoView == nil) {
        _infoView = [[UIView alloc] init];
        [self addSubview:_infoView];
        CGFloat viewLeftWidth = kScreenW / 8;
        CGFloat viewBottomWidth = 20 * AUTO_WIDTH;
        [_infoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(-viewLeftWidth);
            make.top.equalTo(12);
            make.left.equalTo(viewLeftWidth);
            make.bottom.equalTo(self.typeLB.mas_top).equalTo(-viewBottomWidth);
        }];
        
        CGFloat viewWidth = kScreenW / 4;
        CGFloat viewHeight = 60 * AUTO_WIDTH;
        //上牌时间
        UILabel *dateLB = [UILabel new];
        [_infoView addSubview:dateLB];
        [dateLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(0);
            make.width.equalTo(viewWidth);
            make.height.equalTo(viewHeight);
        }];
        dateLB.text = @"上牌时间\n2013-05-13";
        myOwnLBSettings(dateLB);
        
        //行驶公里
        UILabel *driveDistanceLB = [UILabel new];
        [_infoView addSubview:driveDistanceLB];
        [driveDistanceLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(dateLB.mas_right).equalTo(-1);
            make.top.equalTo(0);
            make.width.equalTo(viewWidth);
            make.height.equalTo(viewHeight);
        }];
        driveDistanceLB.text = @"行驶公里\n5万公里";
        myOwnLBSettings(driveDistanceLB);
        
        //车价
        UILabel *carPriceLB = [UILabel new];
        [_infoView addSubview:carPriceLB];
        [carPriceLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(driveDistanceLB.mas_right).equalTo(-1);
            make.top.equalTo(0);
            make.width.equalTo(viewWidth);
            make.height.equalTo(viewHeight);
        }];
        carPriceLB.text = @"车价\n50万";
        myOwnLBSettings(carPriceLB);
        
        //首付信息
        UILabel *firstPayLB = [UILabel new];
        [_infoView addSubview:firstPayLB];
        [firstPayLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(0);
            make.top.equalTo(dateLB.mas_bottom).equalTo(-1);
            make.height.equalTo(viewHeight);
            make.width.equalTo(viewWidth);
        }];
        firstPayLB.text = [NSString stringWithFormat:@"首付\n224100元"];
        myOwnLBSettings(firstPayLB);
        
        //期数信息
        UILabel *payNumLB = [UILabel new];
        [_infoView addSubview:payNumLB];
        [payNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(firstPayLB.mas_right).equalTo(-1);
            make.top.equalTo(driveDistanceLB.mas_bottom).equalTo(-1);
            make.height.equalTo(viewHeight);
            make.width.equalTo(viewWidth);
        }];
        payNumLB.text = [NSString stringWithFormat:@"期数\n36期"];
        myOwnLBSettings(payNumLB);
        
        //月供信息
        UILabel *paymentLB = [UILabel new];
        [_infoView addSubview:paymentLB];
        [paymentLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(payNumLB.mas_right).equalTo(-1);
            make.top.equalTo(carPriceLB.mas_bottom).equalTo(-1);
            make.height.equalTo(viewHeight);
            make.width.equalTo(viewWidth);
        }];
        paymentLB.text = [NSString stringWithFormat:@"月供\n18080元起"];
        myOwnLBSettings(paymentLB);
    }
    return _infoView;
}

- (UILabel *)typeLB {
    if(_typeLB == nil) {
        _typeLB = [[UILabel alloc] init];
        [self addSubview:_typeLB];
        [_typeLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(-8);
            make.bottom.equalTo(-8);
            make.width.equalTo(50);
            make.height.equalTo(20);
        }];
        _typeLB.text = @"二手车";
        _typeLB.numberOfLines = 0;
        _typeLB.textAlignment = NSTextAlignmentCenter;
        _typeLB.font = [UIFont systemFontOfSize:16 * AUTO_WIDTH];
        _typeLB.textColor = [UIColor lightGrayColor];
    }
    return _typeLB;
}
@end
